import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Link } from 'react-router';
import {  Icon,Tabs,message,Row, Col,Input,DatePicker,Button,Table,Form,Select,Cascader,Upload,Modal,Spin,AutoComplete } from 'antd';
import NavBar from '../common/NavBar';
import ContentBody from '../common/ContentBody';
import api from '../api';
import moment from 'moment';


const TabPane = Tabs.TabPane;
const FormItem = Form.Item;
const Option = Select.Option;
const Opt = AutoComplete.Option;
import {
  COMPANY_NATRUE,
} from '../constants/index';

const formItemLayout = {
  labelCol: {
    xs: { span: 24 },
    sm: { span: 4 },
  },
  wrapperCol: {
    xs: { span: 24 },
    sm: { span: 20 },
  },
};

const formItemLayout1 = {
  labelCol:{
    xs:{span:24},
    sm:{span:8},
  },
  wrapperCol:{
    xs:{span:24},
    sm:{span:12}
  }

}

const formItemLayout2 = {
  labelCol:{
    xs:{span:24},
    sm:{span:0},
  },
  wrapperCol:{
    xs:{span:24},
    sm:{span:24}
  }

}

class CompanyCustomEdit extends React.Component {
    constructor(props, context){
        super(props, context);
        var {loan_id,operate_type} = props.location.query||{};
        this.state={
          loading:false,
          provinces:[],
          cities:[],
          regions:[],
          stockPreviewImage:'',
          stockImgPreview:false,
          licenseImgPreview:false,
          stockFileList:[],
          licenseFileList:[],
          custom:{
              license:[],
              equity:[],
          },
          parentCompany:[],
          finalParentCompany:[],
        };
    }
    componentWillMount(){
      this.doFetchProvinces();
      this.doFetchParentCompany();
      let {id} = this.props.location.query||{};
      if (id) {
        this.getDetailById(id);
      }else{
      }
      
    }

    componentWillReceiveProps(nextProps){

    }

    //获取母公司
    async doFetchParentCompany(parentId){
      let result = await api('/system/getParentCompanyList',{});

      this.setState({
          parentCompany:result.parent,
          finalParentCompany:result.finalParent,
        })
      // if (parentId && result.parent.length>0) {
      //   let {custom} = this.state;
      //   result.parent.map((item,index) =>{
      //     if (item.id == parentId) {
      //       custom.parent_company_nature = COMPANY_NATRUE[item.nature];
      //       custom.parent_id = parentId;
      //     }
      //   })
      //   // custom.parent_company_nature = COMPANY_NATRUE[result.parent[parseInt(parentId)].nature];
      //   this.setState({
      //     custom,
      //   })
      // }
    }

    //获取客户公司详细信息
    async getDetailById(id){
      let result = await api('/system/companyCustom/detail',{id});

      if (result.success) {
        this.doFetchCities(result.data.province_code);
        this.doFetchRegions(result.data.city_code);

        // this.doFetchParentCompany(result.data.parent_id);
        let {licenseFileList = [],stockFileList = [],licensePreviewImage,stockPreviewImage,custom,parentCompany} = this.state;
        
        if (result.data && result.data.license && result.data.license.length > 0) {
         
          licenseFileList.push({
            name:result.data.license[0].name,
            url:result.data.license[0].previewUrl,
            uid:result.data.license[0].client_uid,
            status:'done'
          })
          licensePreviewImage = result.data.license[0].previewUrl;
        }
        if (result.data && result.data.equity && result.data.equity.length > 0) {
          
          stockFileList.push({
            name:result.data.equity[0].name,
            url:result.data.equity[0].previewUrl,
            uid:result.data.equity[0].client_uid,
            status:'done'
          })
          stockPreviewImage = result.data.equity[0].previewUrl
        }
        this.setState({
          licenseFileList,
          stockFileList,
          custom:result.data,
        })
      }
      
    }

    
    


    //获取省份
    async doFetchProvinces(){
      this.setState({loading:true});
      var result = await api('/common/getProvinces',{});
      if (result.success) {
        this.setState({
          provinces:result.data,
          loading:false,
        })
      }else{
        this.setState({
          loading:false,
        })
        message.error(result.message);
      }
    }
    //获取城市
    async doFetchCities(provinceCode){
      this.setState({loading:true});
      let result = await api('/common/getCities',{code:provinceCode});
      if (result.success) {
        this.setState({
          cities:result.data,
          loading:false,
        })
      }else{
        this.setState({
          loading:false,
        })
        message.error(result.message);
      }
    }

    //获取地区
    async doFetchRegions(cityCode){
      this.setState({loading:true});
      let result = await api('/common/getRegions',{code:cityCode});
      if (result.success) {
        this.setState({
          regions:result.data,
          loading:false,
        })
      }else{
        this.setState({
          loading:false,
        })
        message.error(result.message);
      }
    }


    //选择省份
    onProvinceChange(value){
      let {custom} = this.state;
      custom.city_code = "";
      custom.area_code = "";
      this.setState({
        custom,
      })
      this.doFetchCities(value);
    }

    //选择城市
    onCityChange(value){
      let {custom} = this.state;
      custom.area_code = "";
      this.setState({
        custom,
      })
      this.doFetchRegions(value);
    }

    //选择地区
    onRegionChange(value){
      // let {custom} = this.state;
      // custom.area_code = value;
      // this.setState({
      //   custom,
      // })
    }

    handleLicenseCancel(){
      this.setState({
        licenseImgPreview:false,
      })
    }

    handleStockCancel(){
        this.setState({
          stockImgPreview:false,
        })
      }

    handleLicensePreview(file){
      this.setState({
          licensePreviewImage: file.url || file.thumbUrl,
          licenseImgPreview: true
      });
    }

    handleStockPreview(file){
      this.setState({
          stockPreviewImage: file.url || file.thumbUrl,
          stockImgPreview: true
      });
        
    }

    handleLicenseChange = ({ fileList }) => {
      
      if (fileList && fileList.length == 0) {
        this.setState({
          licenseFileList:[],
        })
      }
      
      
    }

    handleStockChange = ({ fileList }) => {
      
      if (fileList && fileList.length == 0) {
        this.setState({
          stockFileList:[],
        })
      }
      
      
    }

    uploadStock = (params) =>{
      this.uploadFile(params,"stock");
    }

    uploadLicense = (params) =>{
      this.uploadFile(params,"license");
    }

    //上传
    async uploadFile(params,type){

      let {
        file,
        filename,
      } = params;

      this.setState({
        loading:true
      })
      let {stockFileList=[],licenseFileList=[],custom} = this.state;
      let result 
      if (type == "license") {
        result = await api.upload('/file/upload?file_type=3',file);
      }else{
        result = await api.upload('/file/upload?file_type=2',file);
      }

      if(result.success){
        if (type == "license") {
          licenseFileList.push({
            name:filename,
            url:result.data.previewUrl,
            uid:file.uid,
            status:'done'
          })
          custom.license.push({
            name:result.data.name,
            type:result.data.type,
            url:result.data.url,
            client_uid:file.uid,
          })
          this.setState({
            licenseFileList,
            licensePreviewImage:result.data.previewUrl,
            custom,
          })
        }else{
          stockFileList.push({
            name:filename,
            url:result.data.previewUrl,
            uid:file.uid,
            status:'done'
          })
          custom.equity.push({
            name:result.data.name,
            type:result.data.type,
            url:result.data.url,
            client_uid:file.uid,
          })

          this.setState({
            stockFileList,
            stockPreviewImage:result.data.previewUrl,
            custom,
          })
        }
      }
      this.setState({
        loading:false,
      })
    }



    //保存
    save(addNext){
      const {validateFieldsAndScroll,setFields } = this.props.form;
      validateFieldsAndScroll((errors,values) =>{
        if (errors) {
          return;
        }

        let {custom,loading} = this.state;
        custom  = {...custom,...values};
        let temParentCompany =  this.getParentCompanyIdByName(custom.parent_name);
        if (temParentCompany && temParentCompany.length != 0) {
          custom.parent_id = temParentCompany[0].id;
        }else{
          custom.parent_id = "";
        }
        let temFinalParentCompany = this.getFinalParentCompanyIdByName(custom.final_parent_name);
        if (temFinalParentCompany && temFinalParentCompany.length != 0) {
          custom.final_parent_id = temFinalParentCompany[0].id;
        }else{
          custom.final_parent_id = "";
        }



        let {id} = this.props.location.query||{};
        if (id) {
          this.update(custom);
        }else{
          this.submit(custom,addNext);
        }
        
        
      })

    }

    //保存
    async submit(custom,addNext){
      this.setState({
          loading:true,
        })
        let result = await api('/system/companyCustom/add',{custom});
        this.setState({
            loading:false,
          })
        if (result.success) {
           message.success('保存成功');
          if (addNext == "addNext") {
            const {resetFields} = this.props.form;
            this.setState({
              cities:[],
              regions:[],
              stockPreviewImage:'',
              stockImgPreview:false,
              licenseImgPreview:false,
              stockFileList:[],
              licenseFileList:[],
              custom:{
                  license:[],
                  equity:[],
              },
            })
            resetFields();
            this.context.router.push(`/systemManage/companyCustom/edit`)
          }else{
            this.context.router.push("/systemManage/companyCustom/list")
          }
         
        }else{
          message.error(result.message);
        }
    }

    async update(custom){
      this.setState({
        loading:true,
      })
      let result = await api('/system/companyCustom/update',{custom});
      this.setState({
        loading:false,
      })

      if (result.success) {
        message.success('更新成功');
        this.context.router.push("/systemManage/companyCustom/list")
      
     
      }else{
        message.error(result.message);
      }

    }

    //返回包含name的母公司
    getParentCompanyIdByName(name){
      let {parentCompany} = this.state;
      return parentCompany.filter((item,index) => item.name == name); 
    }


    getFinalParentCompanyIdByName(name){
      let {finalParentCompany} = this.state;
      return finalParentCompany.filter((item,index) => item.name == name); 
    }

    //选择母公司
    onChangeParentCompany(value,opt){
      // console.log('onChangeParentCompany',value);
      // console.log('onChangeParentCompany',opt);
      // console.log('onChangeParentCompany',opt.props.id);
      // let {custom,parentCompany} = this.state;
      // // custom.parent_id = value;
      // custom.parent_id = opt.props.id;
      // this.setState({
      //   custom,
      // })
    }

    onSearchParentCompany(value){
      // console.log('onSearchParentCompany--------',value);
    }

    //选择母公司性质
    onChangeParentNature(value){

    }

    //选择终极母公司
    onChangeFinalParentCompany(value,opt){
      // let {custom} = this.state;
      // custom.final_parent_name = opt.props.name;
      // this.setState({
      //   custom,
      // })
    }

    //终极母公司
    onSearchFinalParentCompany(value){
      // console.log('onSearchFinalParentCompany--------',value);
    }

    //选择终极母公司性质
    onChangeFinalParentNature(value){

    }

    //选择影子评级
    onChangeShadowRating(value){
      // let{custom} = this.state;
      // custom.shadow_rating = value;
      // this.setState({
      //   custom,
      // })
    }

    //选择企业性质
    onChangeNature(value){
      let {custom} = this.state;
      custom.nature = value;
      this.setState({
        custom,
      })
    }


    render() {
      const { getFieldDecorator, getFieldsError, getFieldError, isFieldTouched } = this.props.form;
        let {custom,provinceCode,cityCode,regionCode,provinces,cities,regions,stockImgPreview,stockPreviewImage,
          stockFileList,licenseImgPreview,licensePreviewImage,licenseFileList,parentCompany,finalParentCompany} = this.state;
          let {id} = this.props.location.query || {};
       return (
          <Spin spinning={this.state.loading}>
          <div className="containerWithBorder margin20 bgWhite">
            <div className="margin15">{id?"编辑客户":"添加客户"}</div>
            <div className="padding15 containerWithTopAndBottomBorder" style={{backgroundColor:"#EFEFEF"}}>
              {
                id?
                null
                :
                <Button
                  type="primary"
                  className="marginR15"
                  onClick={this.save.bind(this,"addNext")}
                >保存并继续添加</Button>
              }
              
              <Button
                type="primary"
                className="marginR15"
                onClick={this.save.bind(this,"addOnlyOne")}
              >保存</Button>
              <Button
                type="primary"
                className="marginR15"
                onClick={() => {
                  this.context.router.push("/systemManage/companyCustom/list");
                }}
              >取消</Button>
            </div>
            <h2 className="type-title margin15">基本信息</h2>
            <div className="containerWithBottomBorder marginL15 marginR15"></div>
            <Form className="type-body marginT10 marginL15">
              <Row>
                <Col span={12}>
                    <FormItem 
                      {...formItemLayout}
                      label="公司名称"
                    >
                      {getFieldDecorator('name', {
                        rules: [
                          {
                            required: true,
                            message: '请输入公司名称',
                          },
                        ],
                        initialValue:custom && custom.name?custom.name:"",
                      })(
                        <Input 
                          placeholder="请输入公司名称" 

                        />
                      )}
                      
                    </FormItem>
                </Col>

              </Row>
              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="公司简称"
                  >
                    {getFieldDecorator('short_name', {
                      rules: [
                        {
                          required: true,
                          message: '请输入公司简称',
                        },
                      ],
                      initialValue:custom && custom.short_name?custom.short_name:"",
                    })(
                      <Input 
                        placeholder="请输入公司简称" 
                      />
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <Row>
                <Col span={6}>
                  <FormItem 
                    {...formItemLayout1}
                    label="注册城市"
                  >
                    {getFieldDecorator('province_code', {
                      rules: [
                        {
                          required: true,
                          message: '请选择注册省',
                        },
                      ],
                        initialValue:custom && custom.province_code?custom.province_code.toString():"",
                    })(
                      <Select onChange={this.onProvinceChange.bind(this)} placeholder="请选择省" >
                        <Option key="0" value="">请选择</Option>
                        {
                          provinces.map((item,index) => {
                            return (
                              <Option key={item.code} value={item.code.toString()}>{item.name}</Option>
                              )
                          })
                        }
                      </Select>
                    )}
                      
                  </FormItem>
                </Col>
                <Col span={3}
                style={{marginLeft:"-20px",marginRight:"20px"}}
                >
                  <FormItem 
                    {...formItemLayout2}
                    s
                  >
                    {getFieldDecorator('city_code', {
                      rules: [
                        {
                          required: true,
                          message: '请选择注册城市',
                        },
                      ],
                        initialValue:custom && custom.city_code?custom.city_code.toString():"",
                    })(
                      <Select onChange={this.onCityChange.bind(this)} placeholder="请选择市" >
                        <Option key="0" value="">请选择</Option>
                        {
                          cities.map((item,index) => {
                            return (
                                <Option key={item.code} value={item.code.toString()}>{item.name}</Option>
                              )
                          })
                        }
                      </Select>
                    )}
                      
                  </FormItem>
                </Col>
                <Col span={3}>
                  <FormItem 
                    {...formItemLayout2}
                  >
                    {getFieldDecorator('area_code', {
                      rules: [
                        {
                          required: true,
                          message: '请选择注册地区',
                        },
                      ],
                        initialValue:custom && custom.area_code?custom.area_code.toString():"",
                    })(
                      <Select onChange={this.onRegionChange.bind(this)} placeholder="请选择地区" >
                        <Option key="0" value="">请选择</Option>
                        {
                          regions.map((item,index) => {
                            return (
                                <Option key={item.code} value={item.code.toString()}>{item.name}</Option>
                              )
                          })
                        }
                      </Select>
                    )}
                      
                  </FormItem>
                </Col>

              </Row>
              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="详细地址"
                  >
                    {getFieldDecorator('address', {
                      rules: [
                        {
                          required: true,
                          message: '请输入详细地址',
                        },
                      ],
                        initialValue:custom && custom.address?custom.address.toString():"",
                    })(
                      <Input 
                        placeholder="请输入详细地址" 
                      />
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="所属行业"
                  >
                    {getFieldDecorator('industry', {
                      rules: [
                        {
                          required: true,
                          message: '请输入所属行业',
                        },
                      ],
                      initialValue:custom && custom.industry?custom.industry.toString():"",
                    })(
                      <Input 
                        placeholder="所属行业" 
                      />
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="企业性质"
                  >
                    {getFieldDecorator('nature', {
                      rules: [
                        {
                          required: true,
                          message: '请输入企业性质',
                        },
                      ],
                      initialValue:custom&&custom.nature?custom.nature.toString():"",
                    })(
                      <Select 
                        placeholder="企业性质" 
                        onChange={this.onChangeNature.bind(this)}
                      > 
                        <Option key="0" value="">请选择</Option>
                        <Option key="1" value="STATE_OWNED">国企</Option>
                        <Option key="2" value="PRIVATE">民企</Option>
                        <Option key="3" value="STATE_OWNED_LISTING">国企（上市）</Option>
                        <Option key="4" value="PRIVATE_LISTING">民企（上市）</Option>
                      </Select>
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="法人代表"
                  >
                    {getFieldDecorator('representative', {
                      rules: [
                        {
                          required: true,
                          message: '请输入法人代表',
                        },
                      ],
                      initialValue:custom&&custom.representative?custom.representative.toString():"",
                    })(
                      <Input 
                        placeholder="请输入法人代表" 
                      />
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="母公司"
                  >
                    {getFieldDecorator('parent_name', {
                      rules: [
                        {
                          required: true,
                          message: '请输入母公司',
                        },
                      ],
                      initialValue:custom&&custom.parent_name?custom.parent_name.toString():"",
                    })(


                      <AutoComplete
                        onSelect={this.onChangeParentCompany.bind(this)}
                        onSearch={this.onSearchParentCompany.bind(this)}
                        placeholder="请输入母公司"
                      >
                        {
                          parentCompany.map((item,index) =>{
                            return(
                              <Opt key={item.name}>{item.name}</Opt>
                              )
                          })
                        }
                      </AutoComplete>
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="母公司性质"
                  >
                    {getFieldDecorator('parent_nature', {
                      rules: [
                        {
                          required: true,
                          message: '请选择母公司性质',
                        },
                      ],
                      initialValue:custom&&custom.parent_nature?custom.parent_nature.toString():"",
                    })(
                      <Select 
                        onChange={this.onChangeParentNature.bind(this)}
                      > 
                        <Option key="0" value="">请选择</Option>
                        <Option key="1" value="STATE_OWNED">国企</Option>
                        <Option key="2" value="PRIVATE">民企</Option>
                        <Option key="3" value="STATE_OWNED_LISTING">国企（上市）</Option>
                        <Option key="4" value="PRIVATE_LISTING">民企（上市）</Option>
                      </Select>
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="终极母公司"
                  >
                    {getFieldDecorator('final_parent_name', {
                      rules: [
                        {
                          required: true,
                          message: '请选择终极母公司',
                        },
                      ],
                      initialValue:custom&&custom.final_parent_name?custom.final_parent_name.toString():"",
                    })(
                      <AutoComplete
                        onSelect={this.onChangeFinalParentCompany.bind(this)}
                        onSearch={this.onSearchFinalParentCompany.bind(this)}
                        placeholder="请输入终极母公司"
                      >
                        {
                          finalParentCompany.map((item,index) =>{
                            return(
                              <Opt key={item.name}>{item.name}</Opt>
                              )
                          })
                        }
                      </AutoComplete>
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="终极母公司性质"
                  >
                    {getFieldDecorator('final_parent_nature', {
                      rules: [
                        {
                          required: true,
                          message: '请选择终极母公司性质',
                        },
                      ],
                      initialValue:custom&&custom.final_parent_nature?custom.final_parent_nature.toString():"",
                    })(
                      <Select 
                        onChange={this.onChangeFinalParentNature.bind(this)}
                      > 
                        <Option key="0" value="">请选择</Option>
                        <Option key="1" value="STATE_OWNED">国企</Option>
                        <Option key="2" value="PRIVATE">民企</Option>
                        <Option key="3" value="STATE_OWNED_LISTING">国企（上市）</Option>
                        <Option key="4" value="PRIVATE_LISTING">民企（上市）</Option>
                      </Select>
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="股权关系"
                  >
                    {getFieldDecorator('stockImg', {
                      rules: [
                        {
                          required: false,
                          message: '请上传股权关系',
                        },
                      ],
                    })(
                     <div className="clearfix">
                        <Upload
                            name="stockImg"
                            listType="picture-card"
                            fileList={stockFileList}
                            onPreview={this.handleStockPreview.bind(this)}
                            onChange={this.handleStockChange.bind(this)}
                            accept={'image/*'}
                            customRequest={this.uploadStock}
                        >
                            {stockFileList.length >= 1 ? null : (<div>
                                <Icon type="plus" />
                                <div className="ant-upload-text">添加图片</div>
                            </div>)}
                        </Upload>
                        <Modal visible={stockImgPreview} footer={null} onCancel={this.handleStockCancel.bind(this)}>
                            <img alt="example" style={{ width: '100%' }} src={stockPreviewImage} />
                        </Modal>
                    </div>
                      )
                  }
                  </FormItem>
                </Col>
              </Row>

              <Row>
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="营业执照"
                  >
                    {getFieldDecorator('licenseImg', {
                      rules: [
                        {
                          required: false,
                          message: '请上传营业执照',
                        },
                      ],
                    })(
                      <div className="clearfix">
                        <Upload
                            name="licenseImg"
                            listType="picture-card"
                            fileList={licenseFileList}
                            onPreview={this.handleLicensePreview.bind(this)}
                            onChange={this.handleLicenseChange.bind(this)}
                            accept={'image/*'}
                            customRequest={this.uploadLicense}
                        >
                            {licenseFileList.length >= 1 ? null : (<div>
                                <Icon type="plus" />
                                <div className="ant-upload-text">添加图片</div>
                            </div>)}
                        </Upload>
                        <Modal visible={licenseImgPreview} footer={null} onCancel={this.handleLicenseCancel.bind(this)}>
                            <img alt="example" style={{ width: '100%' }} src={licensePreviewImage} />
                        </Modal>
                      </div>
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <h2 className="type-title margin15">授权信息</h2>
              <div className="containerWithBottomBorder marginL15 marginR15"></div>
              <Row className="marginT10">
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="影子评级"
                  >
                    {getFieldDecorator('shadow_rating', {
                      rules: [
                        {
                          required: true,
                          message: '请选择影子评级',
                        },
                      ],
                      initialValue:custom&&custom.shadow_rating?custom.shadow_rating.toString():"",
                    })(
                      <Select 
                        placeholder="影子评级"
                        onChange={this.onChangeShadowRating.bind(this)}
                      >
                        <Option key="0" value="">请选择</Option>
                        <Option key="1" value="THREE_A">AAA</Option>
                        <Option key="2" value="TWO_A_PLUS">AA+</Option>
                        <Option key="3" value="TWO_A">AA</Option>
                        <Option key="4" value="TWO_A_MINUS">AA-</Option>
                        <Option key="5" value="ONE_A_PLUS">A+</Option>
                        <Option key="6" value="ONE_A">A</Option>
                        <Option key="7" value="ONE_A_MINUS">A-</Option>
                      </Select>
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
              <Row >
                <Col span={12}>
                  <FormItem 
                    {...formItemLayout}
                    label="授信天数"
                  >
                    {getFieldDecorator('credit_day', {
                      rules: [
                        {
                          required: true,
                          message: '请输入授信天数',
                        },
                      ],
                      initialValue:custom&&custom.credit_day?custom.credit_day.toString():"",
                    })(
                      <Input 
                        placeholder="请输入授信天数" 
                      >
                      </Input>
                    )}
                      
                  </FormItem>
                </Col>
              </Row>
            </Form>

          </div>


          </Spin>
          
            
        )
    }
}


CompanyCustomEdit.contextTypes= { router: React.PropTypes.object.isRequired};

export default  Form.create()(CompanyCustomEdit);
